<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户管理</title>
<script type="text/javascript" src="../../static/easyui/jquery.min.js" charset="utf-8"></script>
	<link id="easyuiTheme" rel="stylesheet" href="../../static/easyui/themes/ui-cupertino/easyui.css">
	<link rel="stylesheet" href="../../static/easyui/themes/icon.css">
	<link rel="stylesheet" href="../../static/font/css/font-awesome.min.css">
	<script type="text/javascript" src="../../static/easyui/jquery.easyui.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../static/easyui/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../static/js/easyui_datagrid_yzy.js" charset="utf-8"></script>
	<script type="text/javascript">
	$(function(){
	
		
		var h = document.documentElement.clientHeight || document.body.clientHeight;
		$('#t_table').datagrid({
			url:'pagelist',
			idField:'id',
			pagination:true,	//分页
			pageSize:20,
			
			pageList:[5,10,20],
			height:h-29,
			fitColumns:true,	//宽度是否自适应
			striped:true,	//隔行变色 斑马色
			loadMsg:'数据正在疯狂的加载中...',//加载数据时显示的内容
			rownumbers:true,	//显示序号
			singleSelect:true,	//单选模式
			scrollbarSize:0,	//滚动条宽度
			columns:[ [
				{
					field:'name',
					title:'姓名',
					width:20,
					sortable:true,
					align:"center"
				},{
					field:'username',
					title:'邮箱',
					width:20,
					sortable:true,
					align:"center"
				},{
					field:'sex',
					title:'性别',
					width:10,
					sortable:true,
					align:"center"
				},{
					field:'mynumber',
					title:'电话',
					width:20,
					align:"center",
					sortable:true,
				},{
					field:'number',
					title:'在借图书数量',
					width:20,
					align:"center",
					sortable:true,
					formatter:function(value,record,index){//鼠标悬停显示数据
						if(record.number==0){
							return record.number;
						}else{							
							return record.number+'&emsp;<a onclick="userbooks('+record.id+')" href="#"><marquee  direction="alternate"  scrollamount="15" width="15px" ><i class="fa fa-hand-o-left" style="color: red;"></i></marquee>查看借书详情</a>';
						}
					},
					
				},{
					field:'position',
					title:'身份',
					width:10,
					align:"center",
					sortable:true,
				},{
					field:'dapa',
					title:'所属部门',
					width:10,
					sortable:true,
					align:"center",
					formatter:function(value,record,index){//鼠标悬停显示数据
						return record.dapa.name;
					}
				},{
					field:'bmsRole',
					title:'职务',
					width:20,
					formatter:function(value,record,index){//鼠标悬停显示数据
						var cmd=record.bmsRole[0].name;
						if(cmd=="图书管理员"){
							return "图书管理员"
						}else{
							return "用户"
						}
					},
					styler:function(value,record){/* 给某一个单元格赋予属性 */
						if(record.bmsRole[0].name == "图书管理员"){
							return 'background:#aed0ea';
						}
					}
				}
			] ],
			
		});
		//进行查询
		$('#gobtn').click(function(){
			$('#t_table').datagrid('load', serializeForm($('#mysearch').form()));
		});
		$('#removebtn').click(function(){
			//清空form表单
			$('#mysearch').form('clear');
			$("#t_table").datagrid('load', {});
		});
		$('#sousuo').combotree({    
		    url: '../../administrator/department/treelist'
		});
		$("#sx").click(function(){
			self.location.reload();
		});
	});
	function userbooks(value){
		$('#userbook').show();
		$('#userbook').load('../../admin/br/userbooks?id='+value);
		$('#userbook').dialog({
			autoOpen: true,
			width: 600,
			modal: true,
			draggable: true,
			resizable:false,
			title:"用户借书详情",
			top:100,
			});
	}
	//序列化表单
	function serializeForm(form){
		var obj = {};
		$.each(form.serializeArray(), function(index){
			if(obj[this['name']]){
				obj[this['name']] = obj[this['name']] + ',' + this['value'];
			}else{
				obj[this['name']] = this['value'];
			}
		});
		return obj;
	}
</script>
</head>
<body>
<div id="lay" style="width: 100%;height: 100%;">
		<div region='north' class="easyui-layout" style="height: 28px;background: #f4f4f4;">
			<form action="" id="mysearch" method="post">
				<span style="line-height: 27px;color: #666666;">
					姓名:<input name="name" type="text" value="" class="easyui-textbox" >
					电话：<input name="mynumber" value="" class="easyui-textbox" width="100%" >
					所属部门<input class="easyui-combobox" id="sousuo" style="width: 150px;" name="sousuo"> 
				</span>
				<a class="easyui-linkbutton" iconCls='icon-zoom' id="gobtn">开始检索</a>
				<a class="easyui-linkbutton" iconCls='icon-undo' id="removebtn">清空条件</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-page_white_refresh'" id="sx">刷新子页面</a>
				
			</form>
		</div>
		<div region='center'>
			<table id="t_table"></table>
		</div>
	</div>
	<div id="userbook" style="height: 360px;display: none;" ></div>
</body>
</html>